/**
 * 企业返回和消息中心催单即提醒HR查看简历后的弹窗
 */

$(function(){
    $.resultDialog = function(response){
        if(!response){
            return;
        }
        $('body').append(response);
        dialogShow(".urgeDialog", '.urgeH01,.urgeH02');//催单成功弹窗
    }
    /*----------------------------------begin 弹窗相关的公用方法-----------------------------------------*/
    var $doc = $(document), $window = $(window);
    function dialogShow(name,module){
        addMask();
        $(name+",.full_bg").fadeIn(300);
        $(module).fadeIn(300);
        var winW = $window.width(), winH = $window.height(), scrollTop =$doc.scrollTop();
        var Top = winH/2-($(name).height()/2) + scrollTop;
        var Left = winW/2-($(name).width()/2);
        Top = Top < 0 ? 0 : Top;
        Left = Left < 0 ? 0 : Left;
        $(name).css({"top":Top,"left":Left});
    }
    //添加遮罩层
    function addMask(){
        var maskDiv = $('.full_bg');
        if(maskDiv.length == 0){
            maskDiv = $('<div class="full_bg"></div>');
            $('body').append(maskDiv);
        }
        maskDiv.css({
            width : $window.width(),
            height : $window.height()
        });
    }
    //浏览器改变大小和滑动滚动条调整弹窗位置
    $(window).on('resize scroll', function(){
        //弹窗
        var dialog = $('.dialog');
        if(dialog.length > 0){
            var top, left;
            var offset_topWin = $window.height() - dialog.height();
            var offset_leftWin = ($window.width() - dialog.width())/2;
            if(offset_topWin < 0){
                if($window.height() + $doc.scrollTop() >= $(document).height()){
                    top = $doc.scrollTop() + offset_topWin;
                }else{
                    top = $doc.scrollTop();
                }
            }else{
                top = offset_topWin/2 + $doc.scrollTop();
            }
            if(offset_leftWin <= 0){
                left = $doc.scrollLeft() - 10;
            }else{
                left = offset_leftWin + $doc.scrollLeft();
            }
            dialog.css({
                top : top,
                left : left
            });
        }
    });
    //浏览器改变大小时调整遮罩大小
    $(window).on('resize', function(){
        //遮罩
        var maskDiv = $('.full_bg');
        if(maskDiv.length > 0){
            maskDiv.css({
                width : $doc.width(),
                height : $doc.height()
            });
        }
    });
    //调用该方法关闭弹窗
    function dialogClose(){
        $(".dialog,.full_bg").fadeOut(300, function(){$(this).remove();});
    }
    //通过关闭按钮关闭弹窗
    $(document).on('click', ".dialog .close", function(){
        $(".dialog,.full_bg").fadeOut(300, function(){$(this).remove();});
    });
    /*----------------------------------end 弹窗相关的公用方法-----------------------------------------*/
});
//催单成功弹窗中推荐职位的单个职位申请
function application(obj) {
    var $obj = $(obj), resumenumber = $obj.data("resumenumber"), city = $obj.data("city"),
        applytype = $obj.data("applytype"), jk = $obj.data("jk");
    zlzp.searchjob.ajaxApply({ no: "", num: 1, ok: resumenumber + "_" + city + "_" + applytype + "_" + jk }, "");
    return false;
}










